#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from common.readelement import Element
from page_object.webpage import WebPage
from tools.logger import log

viewpartjob = Element('jzsz/enterprise/view_partjob')

class ViewParttimeJobPage(WebPage):

    def open_parttimeapplylist(self):
        """打开兼职报名列表"""
        self.is_click(viewpartjob['用户信息'])
        self.is_click(viewpartjob['岗位管理'])
        self.is_click(viewpartjob['报名人员信息'])

    def get_reach_intention_num(self):
        """查看达成意向数量"""
        self.is_click(viewpartjob['达成意向tab'])
        res = self.is_exists2(viewpartjob['总量'])
        if res:
            text = self.find_element(viewpartjob['总量']).text
            resume_num = text[2:-2]
            return resume_num
        else:
            return '0'

    def reach_partintention(self):
        """达成意向"""
        self.is_click(viewpartjob['待处理tab'])
        self.is_click(viewpartjob['达成意向'])
        self.is_click(viewpartjob['确定'])

    def opera_result(self,resume_num):
        """验证达成意向操作成功"""
        self.is_click(viewpartjob['达成意向tab'])
        res = self.is_exists2(viewpartjob['总量'])
        if res:
            text = self.find_element(viewpartjob['总量']).text
            resume_num2 = text[2:-2]
            if int(resume_num2) == int(resume_num) + 1:
                return True
            else:
                return False
        else:
            return False
